import { IRouteData, IRouteLine } from './interface'

/** 扁平化数据 */
export const flatteRouteData = (data: IRouteData[]): IRouteLine[] => {
  if (data.length <= 0) return [] as IRouteLine[]
  return data
    .map(item => {
      const { logisticsStatusCn, logisticsStatusEn, nodeInfoList } = item

      console.log('nodeInfoList', nodeInfoList)
      const currentNode = nodeInfoList.map(node => ({
        logisticsStatusCn,
        logisticsStatusEn,
        ...node,
        isTitle: 0,
      }))
      currentNode.unshift({ ...nodeInfoList?.[0], logisticsStatusCn, logisticsStatusEn, isTitle: 1 })
      return currentNode
    })
    .flat() // 使用flat()将嵌套数组扁平化
}
